home *** CD-ROM | disk | FTP | other *** search
- package opera;
-
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.net.HttpURLConnection;
- import java.net.URL;
- import java.util.Enumeration;
- import java.util.Hashtable;
-
- public class OperaURLConnection extends HttpURLConnection {
- // $FF: renamed from: is opera.OperaInputStream
- private OperaInputStream field_0 = null;
- private int istream_id = -1;
- // $FF: renamed from: os opera.OperaOutputStream
- private OperaOutputStream field_1 = null;
- private int ostream_id = -1;
- private Hashtable req_props = new Hashtable();
-
- protected OperaURLConnection(URL var1) {
- super(var1);
- }
-
- public void connect() throws IOException {
- if (!super.connected) {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkConnect(super.url.getHost(), super.url.getPort());
- }
-
- try {
- this.field_0 = new OperaInputStream(this);
- this.field_1 = new OperaOutputStream(this);
- this.istream_id = OperaInputStream.addStream(this.field_0);
- this.ostream_id = OperaOutputStream.addStream(this.field_1);
- this.field_1.istream_id = this.istream_id;
- if (super.method.compareTo("POST") == 0) {
- Object var2 = PluginContext.opera_mutex;
- synchronized(var2) {
- this.nativeConnect(super.url.toString(), super.method, this.ostream_id);
- }
-
- super.connected = true;
- } else {
- Object var11 = PluginContext.opera_mutex;
- synchronized(var11) {
- this.nativeConnect(super.url.toString(), super.method, this.istream_id);
- }
-
- try {
- OperaInputStream var4 = this.field_0;
- synchronized(var4) {
- this.field_0.wait();
- }
- } catch (InterruptedException var7) {
- Thread.currentThread().interrupt();
- }
-
- if (this.field_0.getResponse() != 200) {
- super.connected = false;
- } else {
- super.connected = true;
- }
- }
- } catch (Exception var10) {
- ((Throwable)var10).printStackTrace(System.err);
- }
-
- if (!super.connected) {
- throw new IOException("Connection failed.");
- }
- }
-
- }
-
- private native void nativeConnect(String var1, String var2, int var3);
-
- public InputStream getInputStream() throws IOException {
- if (!super.connected) {
- this.connect();
- }
-
- if (super.method.compareTo("POST") == 0) {
- if (this.field_0.getResponse() == -1) {
- try {
- OperaInputStream var1 = this.field_0;
- synchronized(var1) {
- this.field_0.wait();
- }
- } catch (InterruptedException var4) {
- Thread.currentThread().interrupt();
- }
- }
-
- if (this.field_0.getResponse() != 200) {
- System.out.println("HTTP Response: " + this.field_0.getResponse());
- super.connected = false;
- throw new FileNotFoundException(super.url.toString());
- }
-
- super.connected = true;
- }
-
- return this.field_0;
- }
-
- public int getContentLength() {
- if (!super.connected) {
- try {
- this.connect();
- } catch (Exception var2) {
- }
- }
-
- return this.field_0 != null ? this.field_0.getContentLength() : 0;
- }
-
- public OutputStream getOutputStream() throws IOException {
- super.method = "POST";
- if (!super.connected) {
- this.connect();
- }
-
- return this.field_1;
- }
-
- public String getHeaderField(String var1) {
- return super.getHeaderField(var1);
- }
-
- public String getRequestProperty(String var1) {
- return (String)this.req_props.get(var1);
- }
-
- public void setRequestProperty(String var1, String var2) {
- this.req_props.put(var1, var2);
- }
-
- public void disconnect() {
- }
-
- public boolean usingProxy() {
- return false;
- }
-
- protected void finalize() throws Throwable {
- if (this.field_0 != null) {
- this.field_0 = null;
- OperaInputStream.removeStream(this.istream_id);
- }
-
- if (this.field_1 != null) {
- this.field_1 = null;
- OperaOutputStream.removeStream(this.ostream_id);
- }
-
- super.finalize();
- }
-
- protected String makeExtraHeaders() {
- String var1 = "";
- Enumeration var2 = this.req_props.keys();
- Enumeration var3 = this.req_props.elements();
-
- while(var2.hasMoreElements()) {
- var1 = var1.concat((String)var2.nextElement());
- String var4 = (String)var3.nextElement();
- if (var4 != null) {
- var1 = var1.concat(": " + var4 + "\n\r");
- } else {
- var1 = var1.concat("\n\r");
- }
- }
-
- return var1;
- }
- }
-